﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Serialization;
using System.IO;
using System.Configuration;
using PS.Framework.Xml;

namespace PS.Framework.EventLogger
{
    public class LoggerConfiguration
    {
        public string EventSource
        {
            get;
            set;
        }
        public string EventLog
        {
            get;
            set;
        }
        public LogType LogType
        {
            get;
            set;
        }
        public string LogFile
        {
            get;
            set;
        }

        public string Delimiter
        {
            get;
            set;
        }

        public static LoggerConfiguration LoadConfiguration()
        {
            XmlSerializer<LoggerConfiguration> xmlSerializer = new XmlSerializer<LoggerConfiguration>();
            
            string text = null;
            text = ConfigurationManager.AppSettings["ConfigFile_Event"];
            if (string.IsNullOrEmpty(text))
            {
                text = "ConfigFile_Event.xml";
            }
            LoggerConfiguration result = null;
            if (File.Exists(text))
            {
                 result = xmlSerializer.Deserialize(text);                   
            }
            return result;
        }
    }
}
